package com.ruoyi.cbs.contract.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.uuid.IdFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.cbs.contract.mapper.ContractorPersonnelCertMapper;
import com.ruoyi.cbs.contract.domain.ContractorPersonnelCert;
import com.ruoyi.cbs.contract.service.IContractorPersonnelCertService;

/**
 * 承包商人员资质Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-11-21
 */
@Service
public class ContractorPersonnelCertServiceImpl implements IContractorPersonnelCertService 
{
    @Autowired
    private ContractorPersonnelCertMapper contractorPersonnelCertMapper;

    /**
     * 查询承包商人员资质
     * 
     * @param id 承包商人员资质主键
     * @return 承包商人员资质
     */
    @Override
    public ContractorPersonnelCert selectContractorPersonnelCertById(Long id)
    {
        return contractorPersonnelCertMapper.selectContractorPersonnelCertById(id);
    }

    /**
     * 查询承包商人员资质列表
     *
     * @param personnelId 承包商人员主键
     * @return 承包商人员资质
     */
    @Override
    public List<ContractorPersonnelCert> selectListByPersonnelId(Long personnelId)
    {
        ContractorPersonnelCert contractorPersonnelCert = new ContractorPersonnelCert();
        contractorPersonnelCert.setPersonnelId(personnelId);
        contractorPersonnelCert.setStatus("1");
        return this.selectContractorPersonnelCertList(contractorPersonnelCert);
    }

    /**
     * 查询承包商人员资质列表
     * 
     * @param contractorPersonnelCert 承包商人员资质
     * @return 承包商人员资质
     */
    @Override
    public List<ContractorPersonnelCert> selectContractorPersonnelCertList(ContractorPersonnelCert contractorPersonnelCert)
    {
        return contractorPersonnelCertMapper.selectContractorPersonnelCertList(contractorPersonnelCert);
    }

    /**
     * 新增承包商人员资质
     * 
     * @param contractorPersonnelCert 承包商人员资质
     * @return 结果
     */
    @Override
    public int insertContractorPersonnelCert(ContractorPersonnelCert contractorPersonnelCert)
    {
        contractorPersonnelCert.setCreateTime(DateUtils.getNowDate());
        contractorPersonnelCert.setId(IdFactory.newLongId());
        if (contractorPersonnelCert.getCreateBy() == null) {
            contractorPersonnelCert.setCreateBy("admin");
        }
        return contractorPersonnelCertMapper.insertContractorPersonnelCert(contractorPersonnelCert);
    }

    /**
     * 修改承包商人员资质
     * 
     * @param contractorPersonnelCert 承包商人员资质
     * @return 结果
     */
    @Override
    public int updateContractorPersonnelCert(ContractorPersonnelCert contractorPersonnelCert)
    {
        contractorPersonnelCert.setUpdateTime(DateUtils.getNowDate());
        return contractorPersonnelCertMapper.updateContractorPersonnelCert(contractorPersonnelCert);
    }

    /**
     * 批量删除承包商人员资质
     * 
     * @param ids 需要删除的承包商人员资质主键
     * @return 结果
     */
    @Override
    public int deleteContractorPersonnelCertByIds(Long[] ids)
    {
        return contractorPersonnelCertMapper.deleteContractorPersonnelCertByIds(ids);
    }

    /**
     * 删除承包商人员资质信息
     * 
     * @param id 承包商人员资质主键
     * @return 结果
     */
    @Override
    public int deleteContractorPersonnelCertById(Long id)
    {
        return contractorPersonnelCertMapper.deleteContractorPersonnelCertById(id);
    }
}
